package com.itheima.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.Settings;
import com.itheima.mapper.SettingsMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

@DubboService
public class SettingsApiImpl implements SettingsApi{

    @Resource
    private SettingsMapper settingsMapper;

    /**
     * 根据id查设置
     * @param userId
     * @return
     */
    @Override
    public Settings findByUserId(Long userId) {
        LambdaQueryWrapper<Settings> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Settings::getUserId,userId);
        return settingsMapper.selectOne(queryWrapper);
    }

    @Override
    public void save(Settings settings) {
        settingsMapper.insert(settings);
    }

    @Override
    public void update(Settings settings) {
        settingsMapper.updateById(settings);
    }


}
